<?php 
require_once ('../../conexion/conexion.php');
require_once ('../../lib/utils.php');

$genero = $_GET['genero'];
$fecha1 = fechaguardar($_GET['fecha1']);
$fecha2 = fechaguardar($_GET['fecha2']);
$CodAuto=Autoempleo;
$query_grafic = "SELECT  CTC.CTC_NOMBRE, COUNT(CTC.CTC_NOMBRE) AS CANT
					FROM PERSONA PER INNER JOIN PERSONAS_CON_DISCAPACIDAD PCD ON PCD.PER_CODIGO = PER.PER_CODIGO 
					INNER JOIN EXPEDIENTE EXPE ON EXPE.EXP_CODIGO = PCD.EXP_CODIGO
					INNER JOIN PERSONA_SELECCIONADA PES ON PES.EXP_CODIGO = PCD.EXP_CODIGO
					INNER JOIN OFERTA OFE ON OFE.OFE_CODIGO = PES.OFE_CODIGO
					INNER JOIN CAT_TIPO_CONTRATO CTC ON CTC.CTC_CODIGO = OFE.CTC_CODIGO
					WHERE EXPE.CEE_CAE_CODIGO = $CodAuto
					AND EXPE.EXP_FECHA_CREACION BETWEEN '$fecha1' AND DATE_ADD('$fecha2', INTERVAL 1 DAY)
					AND PER.PER_GENERO = '$genero'
					GROUP BY CTC.CTC_NOMBRE";

$grafic = mysql_query($query_grafic);
 // content="text/plain; charset=utf-8"
require_once ('../../clase/jpgraph/jpgraph.php');
require_once ('../../clase/jpgraph/jpgraph_pie.php');
require_once ('../../clase/jpgraph/jpgraph_pie3d.php');
 
$datay=array();
$labelx=array();
 
while ($row_grafic = mysql_fetch_array($grafic)) {
$labelx[] = $row_grafic["CTC_NOMBRE"];
$datay[] = $row_grafic["CANT"];
}
 
$data = $datay;
$graph = new PieGraph(1200,800);
$graph->img->SetAntiAliasing();
$graph->SetMarginColor('black');
$graph->SetShadow();

$graph->title->Set('Reporte de personas autoempleadas');
$graph->title->SetFont(FF_ARIAL,FS_NORMAL,30);
$graph->title->SetColor("white");


$p1 = new PiePlot3D($data);
$p1->SetTheme("earth");
$p1->SetSize(0.35);
$p1->SetCenter(0.5);



// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_FONT1,FS_BOLD);
$p1->value->SetColor("black");
$p1->SetLabelPos(0.2); 

$p1->SetLegends($labelx);
 
// Setup slice labels and move them into the plot
$p1->value->SetFont(FF_ARIAL,FS_BOLD,25);
$p1->value->SetColor("white");
$p1->SetLabelPos(0.5);
// Explode all slices
$p1->ExplodeAll();
$graph->Add($p1);
$graph->Stroke();
 
mysql_free_result($grafic);
?>
